<template>
  <div id="root">
    <Top><p>确认订单</p></Top>
    <van-contact-card
        type="edit"
        :name="dizhi.name"
        :tel="dizhi.phone"
        @click="onEdit"
    />
<div class="deliveryTime">
  <h2>送达时间</h2>
  <div>
    <h3>尽快送达|预计18:06</h3>
    <van-button class="deliveryTimeIom" type="primary" size="mini">蜂鸟专送</van-button>
</div>
</div>

    <div class="payment">
      <p><span>支付方式</span> <span @click="show=true">在线支付 <van-icon name="arrow" /></span></p>
      <p><span>红包</span> <span>暂时只能在饿了么app中支持</span></p>
    </div>
    <van-popup v-model="show" position="bottom" :style="{ height: '30%' }">
      <div class="show-bottom"><p>支持方式</p>
      <p> 货到付款(商家不支持货到付款)</p>
        <p>在线支付 <van-checkbox v-model="checked" checked-color="#07c160"></van-checkbox></p>
      </div>
    </van-popup>
    <div class="cmm">
      <div>
         <img :src="'https://elm.cangdu.org/img/'+shop.image_path" alt="">
         <h3 class="cmm-h3">{{shop.name}}</h3>
      </div>

      <div>

        <div v-for="(v,i) in corder" :key="i" class="cmmtiao"><p>{{v.name}} <span v-show="v.specs">---{{v.specs}}</span></p> <div> <span>X{{v.quantity}}</span> <span>¥{{v.price}}</span></div></div>
        <div class="cmmtiao"><p>餐盒</p> <div> <span></span> <span>¥{{messsum}}</span></div></div>
        <div class="cmmtiao"><p>配送费</p> <div> <span></span> <span>¥{{shop.float_delivery_fee}}</span></div></div>
        <div class="cmmtiao"><p>订单{{sum+messsum}}</p> <div> <span></span> <span>待支付¥{{sum+messsum}}</span></div></div>
        <div class="cmmtiao">
          <p>订单备注 </p> <span></span>  <span @click="pianhao()"><span v-for="(v,i) in pianhao3" :key="i">{{v}},</span><van-icon name="arrow" /></span>
        </div>
        <div class="cmmtiao">
          <p>发票抬头 </p> <span></span>  <span>不需要开发票</span>
        </div>
      </div>

    </div>
    <div class="bottom">
<p>待支付{{sum+messsum}}</p>
      <p @click="$router.push('/ddpayment')">确认下单</p>
    </div>
<router-view></router-view>
  </div>
</template>

<script>
import Top from "@/components/Top";
import {mapState} from "vuex";
export default {
name: "Close",
  components: {Top},
  data() {
    return {
      currentContact: {
        name: '张三',
        tel: '13000000000',
      },
      show:false,//弹出层
      checked:true,//复选框
     pianhao2:["口味",'偏好等'],
    };
  },
  methods: {
    onEdit() {
      // Toast('编辑');
      this.$router.push('/close/chooseAddress');

    },
    pianhao(){
      this.$router.push('/close/ddremarks');
    },

  },
  computed: {
   // ...mapGetters(["corder"])
    ...mapState(["corder","shop","sum",'dizhi']),
    messsum(){
      let sum=0;
      for (let i in this.$store.state.corder){
        let Obj=this.$store.state.corder[i];
        sum+=Obj.packing_fee;
      }
      return sum;
    },
    pianhao3(){
      return this.pianhao2;
    },

  },
  created() {
  this.$on("remark_event",(a)=>{
    console.log(a)
    this.pianhao2=a
    console.log(this.pianhao2)

  })
  },

}
</script>

<style scoped>
.deliveryTime{
  border-left: .2rem solid #3190e8;
  min-height: 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  margin-top: 10px;
  background-color: #fff;
}
.deliveryTimeIom{
  float: right;
}
.deliveryTime h2{
  font-size: 1.3rem;
  color: #333;
  font-weight: 700;
  padding-left: .3rem;
}
.deliveryTime h3{
  font-size: 1rem;
  color: #3190e8;
  padding-bottom: 10px;
}
.payment{
  background-color: #fff;
  margin-top: .4rem;
  padding: 0 .7rem;
}
.payment p{
  padding: 0;
  margin: 0;
  color: #333;
  font-weight: 400;
  display: flex;
  padding: 10px;
  justify-content: space-between;
  font-family: Microsoft Yahei;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
.payment p:nth-child(2){
  border-top: .025rem solid #f5f5f5;
}
.cmm{
  background-color: #fff;
  margin-bottom: 40px;
  height: 285px;
  overflow-y: auto;
}
.cmm div:nth-child(1){
  margin: 0;
  color: #333;
  font-weight: 400;
  font-family: Microsoft Yahei;
  box-sizing: border-box;
  padding: .7rem;
  display: flex;
  border-bottom: .025rem solid #f5f5f5;
}
.cmm-h3{
  font-size: 1.2rem;
  color: #333;
  margin-left: 10px;
}

.cmm img{
  width: 2.9rem;
  height: 2.9rem;
  display: block;
  border-radius: .15rem;
}
.cmmtiao{
  display: flex;
  justify-content: space-between;
  line-height: 1.8rem;
  padding: 0 .7rem;

}
.cmmtiao p{
  width: 70%;
  font-size: 1.05rem;
  color: #666
}
.cmmtiao div{
  flex: 1;
  display: flex;
  width: 30%;
  justify-content: space-between;
  align-items: center;
}
.cmmtiao div span:nth-child(1){
  color: #f60;
}
.bottom{
  display: flex;
  justify-content: space-between;
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 40px;
  color: #fff;
  background-color: #3c3c3c;
}
.bottom p:nth-child(2){
  background-color: #56d176;
  text-align: center;
  width: 40%;
  font-size: 1.2rem;
  line-height: 40px;
}
.bottom p:nth-child(1){
  line-height: 40px;
  font-size: 1.1rem;
  background-color: #3c3c3c;
  -ms-flex: 5;
  flex: 5;
  padding-left: .7rem;
}
.show-bottom p:nth-child(1){
  background-color: #fafafa;
  font-size: 1.5rem;
  color: #333;
  text-align: center;
  line-height: 3rem;
}
.show-bottom p:nth-child(2){
  display: flex;
  justify-content: space-between;
  padding: 0 .7rem;
  line-height: 3.5rem;
  align-items: center;
  font-size: 1rem;
  color: #ccc;

}
.show-bottom p:nth-child(3){
  display: flex;
  justify-content: space-between;
  padding: 0 .7rem;
  line-height: 2.5rem;
  align-items: center;
}

</style>